package com.neouton.crm.pm.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.neouton.common.util.PageUtil;
import com.neouton.crm.pm.entity.BillingApplyDto;
import com.neouton.crm.pm.entity.PurchaseOrderProductVO;
import com.neouton.crm.pm.entity.PurchaseOrderVO;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 合同相关Service
 * @Author libingkun
 * @Date 2022年11月30日
 * @Version 1.0
 *          初始化迁移
 */
public interface IPurchaseOrdeService {

    /**
     * 保存采购信息
     * @param purchaseOrder
     * @return
     */
    Integer saveOrUpdatePurchaseOrder(PurchaseOrderVO purchaseOrder,String token);

    /**
     * 获取当日最大采购单号
     * @return
     */
    String getPurchaseOrdeMaxNumByDate();

    /**
     * 更具项目ID获取所有采购信息
     */
    List<PurchaseOrderVO> queryPurchaseOrdersByProjectId(Integer projectId);

    /**
     * 更具机会ID查询采购信息
     */
    List<PurchaseOrderVO> queryPurchaseOrdersByOpId(Integer opId);

    /**
     * 更具采购单ID获取采购信息
     * @param purchaseOrdeId
     * @return
     */
    PurchaseOrderVO getPurchaseOrdeInfoById(Integer purchaseOrdeId);


    /**
     * 采购信息驳回审批
     * @param purchaseOrder
     * @return
     */
    Boolean rejectionPurchaseOrderInfo(PurchaseOrderVO purchaseOrder, String token);

    /**
     * 采购信息通过审批
     * @param purchaseOrder
     * @return
     */
    Boolean approvePurchaseOrderInfo(PurchaseOrderVO purchaseOrder,String token,Boolean auto);

    /**
     * 通过申请表主键查询现有数据
     * @param approvalId
     * @return
     */
    PurchaseOrderVO queryPurchaseOrderByApprovalId(Integer approvalId);

    /**
     * 通过申请表主键查询历史
     * @param approvalId
     * @return
     */
    PurchaseOrderVO queryPurchaseOrderHistoryByApprovalId(Integer approvalId);

    List<PurchaseOrderVO> getPurOrdeInfoById(int purchaseOrdeId);

    List<PurchaseOrderVO> getPurchaseById(Integer contractId);

    List<PurchaseOrderVO> getWmsProjectInfo(Integer contractId);

    List<BillingApplyDto> getAllContract(Integer projectManageId);

    /**
     * 分页查询
     *
     * @param page
     * @param entity
     * @return
     */
    PageUtil<PurchaseOrderVO> queryPurchaseOrdesByPage(IPage page, PurchaseOrderVO entity, String token);

    /**
     * 分页查询待办信息
     *
     * @param page
     * @param entity
     * @return
     */
    PageUtil<PurchaseOrderVO> queryApprovalPurByPage(IPage page, PurchaseOrderVO entity);


    /**
     * 分页查询已办信息
     *
     * @param page
     * @param entity
     * @return
     */
    PageUtil<PurchaseOrderVO> queryApprovalPurDoneByPage(IPage page, PurchaseOrderVO entity);

    /**
     * 分页查询申请记录信息
     *
     * @param page
     * @param entity
     * @return
     */
    PageUtil<PurchaseOrderVO> queryApprovalPurRecordByPage(IPage page, PurchaseOrderVO entity,String token);

    /**
     * 一指禅系统产品列表导出
     *
     * @param response
     */
    void exportPurchaseOrdes(HttpServletResponse response, PurchaseOrderVO entit, String token) throws Exception;

    /**
     * 分页查询
     *
     * @param page
     * @param entity
     * @return
     */
    PageUtil<PurchaseOrderProductVO> queryPurchaseProductsByPage(IPage page, PurchaseOrderProductVO entity, String token);

    /**
     * 导出采购明细数据
     */
    void exportPurchaseProducts(HttpServletResponse response, PurchaseOrderProductVO entit, String token) throws Exception;

    /**
     * 更据采购ID获取采购相关付款 收票记录
     * @param purId
     * @return
     */
    Map<String, BigDecimal> queryPurPayInfoByPurId(Integer purId);

    /**
     * 更据项目ID获取采购相关付款 收票记录
     * @param proId
     * @return
     */
    Map<String, BigDecimal> queryPurPayInfoByProId(Integer proId);


    Map<String, BigDecimal> queryPurPayInfoByCustomerId(Integer customerId,String token);

    Map<String, BigDecimal> queryPurPayInfoBySupplierId(Integer supplierId, String token);

    Boolean deletePurchaseOrderById(Integer purchaseOrdeId);

    void updatePurchaseOrdeAfterPass(PurchaseOrderVO purchaseOrderVO, String token);

    PurchaseOrderVO queryPurchaseOrdeFromCache(int purchaseId, String token);

    List<PurchaseOrderVO> selectAllProjectByPur();

    List<PurchaseOrderVO> selectAllProjectByPurCreate(String token);

    PageUtil<PurchaseOrderVO> queryRefundDetailsByPage(IPage page, PurchaseOrderVO entity);

    Map<String, String> queryRefundCharData();

    void exportRefundDetails(HttpServletResponse response, PurchaseOrderVO entit) throws Exception;
}
